/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tpdisenio2009.model.beans;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author DeuterioX
 */
@Entity
@Table(name = "fantasy_team")
@NamedQueries({
    @NamedQuery(name = "FantasyTeam.findAll", query = "SELECT f FROM FantasyTeam f")})
public class FantasyTeam implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;

    @Basic(optional = false)
    @Column(name = "creation_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date creationDate;

    @Basic(optional = false)
    @Column(name = "name", nullable=false)
    private String name;

    @Basic(optional = false)
    @Column(name = "total_score")
    private int totalScore;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fantasyTeam")
    private Collection<FantasyTeamPlayer> fantasyTeamPlayerCollection;

    @JoinColumn(name = "id_user", referencedColumnName = "id")
    @OneToOne(optional = false)
    private User user;

    public FantasyTeam() {
    }

    public FantasyTeam(Integer id) {
        this.id = id;
    }

    public FantasyTeam(Integer id, Date creationDate, String name, int totalScore) {
        this.id = id;
        this.creationDate = creationDate;
        this.name = name;
        this.totalScore = totalScore;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(int totalScore) {
        this.totalScore = totalScore;
    }

    public Collection<FantasyTeamPlayer> getFantasyTeamPlayerCollection() {
        return fantasyTeamPlayerCollection;
    }

    public void setFantasyTeamPlayerCollection(Collection<FantasyTeamPlayer> fantasyTeamPlayerCollection) {
        this.fantasyTeamPlayerCollection = fantasyTeamPlayerCollection;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FantasyTeam)) {
            return false;
        }
        FantasyTeam other = (FantasyTeam) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tpdisenio2009.model.beans.FantasyTeam[id=" + id + "]";
    }

}
